Fix music streaming.
This commit is contained in:
		@@ -22,7 +22,6 @@ official CMA and also offer some features missing in the original one.
 | 
			
		||||
#### TODO:
 | 
			
		||||
* Complete categories for music.
 | 
			
		||||
* SQLite backend for database.
 | 
			
		||||
* Fix streaming for music.
 | 
			
		||||
 | 
			
		||||
## Planned features
 | 
			
		||||
* **UPNP bridge**: connect an existing UPNP server to interface with the Vita
 | 
			
		||||
 
 | 
			
		||||
@@ -348,7 +348,7 @@ void CmaEvent::vitaEventSendObjectMetadata(vita_event_t *event, int eventId)
 | 
			
		||||
    QMutexLocker locker(&db->mutex);
 | 
			
		||||
 | 
			
		||||
    metadata_t *meta;
 | 
			
		||||
    int count = db->filterObjects(browse.ohfiParent, &meta);  // if meta is null, will return empty XML
 | 
			
		||||
    int count = db->filterObjects(browse.ohfiParent, &meta, browse.index, browse.numObjects);  // if meta is null, will return empty XML
 | 
			
		||||
    qDebug("Sending %i metadata filtered objects for OHFI %d", count, browse.ohfiParent);
 | 
			
		||||
 | 
			
		||||
    if(VitaMTP_SendObjectMetadata(device, eventId, meta) != PTP_RC_OK) {  // send all objects with OHFI parent
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										16
									
								
								database.cpp
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								database.cpp
									
									
									
									
									
								
							@@ -406,7 +406,7 @@ void Database::dumpMetadataList(const metadata_t *p_head)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int Database::filterObjects(int ohfiParent, metadata_t **p_head)
 | 
			
		||||
int Database::filterObjects(int ohfiParent, metadata_t **p_head, int index, int max_number)
 | 
			
		||||
{
 | 
			
		||||
    QMutexLocker locker(&mutex);
 | 
			
		||||
    CMARootObject *parent = static_cast<CMARootObject *>(ohfiToObject(ohfiParent));
 | 
			
		||||
@@ -430,6 +430,7 @@ int Database::filterObjects(int ohfiParent, metadata_t **p_head)
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    int offset = 0;
 | 
			
		||||
    int numObjects = 0;
 | 
			
		||||
    metadata_t temp = metadata_t();
 | 
			
		||||
    metadata_t *tail = &temp;
 | 
			
		||||
@@ -437,9 +438,16 @@ int Database::filterObjects(int ohfiParent, metadata_t **p_head)
 | 
			
		||||
    for(map_list::iterator root = object_list.begin(); root != object_list.end(); ++root) {
 | 
			
		||||
        for(root_list::iterator object = (*root).begin(); object != (*root).end(); ++object) {
 | 
			
		||||
            if(acceptFilteredObject(parent, *object, type)) {
 | 
			
		||||
                tail->next_metadata = &(*object)->metadata;
 | 
			
		||||
                tail = tail->next_metadata;
 | 
			
		||||
                numObjects++;
 | 
			
		||||
                if(offset++ >= index)
 | 
			
		||||
                {
 | 
			
		||||
                    tail->next_metadata = &(*object)->metadata;
 | 
			
		||||
                    tail = tail->next_metadata;
 | 
			
		||||
                    numObjects++;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if(max_number > 0 && numObjects >= max_number) {
 | 
			
		||||
                    break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -49,7 +49,7 @@ public:
 | 
			
		||||
    bool find(int ohfi, find_data &data);
 | 
			
		||||
    void append(int parent_ohfi, CMAObject *object);
 | 
			
		||||
    bool remove(const CMAObject *obj, int ohfi_root = 0);
 | 
			
		||||
    int filterObjects(int ohfiParent, metadata_t **p_head);
 | 
			
		||||
    int filterObjects(int ohfiParent, metadata_t **p_head, int index = 0, int max_number = 0);
 | 
			
		||||
    CMAObject *pathToObject(const char *path, int ohfiRoot);
 | 
			
		||||
    int acceptFilteredObject(const CMAObject *parent, const CMAObject *current, int type);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user