fix SetMetaData to create an area, do not bother with checking the return value from find_thread(NULL)

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6259 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
shatty
2004-01-24 22:19:00 +00:00
parent bacf4b5e20
commit a4f26c7d66
+22 -3
View File
@@ -626,8 +626,29 @@ status_t
media_format::SetMetaData(const void *data, media_format::SetMetaData(const void *data,
size_t size) size_t size)
{ {
meta_data = data; // TODO: create_area / delete_area for this should be done by the media server?
if (meta_data_area > 0) {
delete_area(meta_data_area);
}
uchar * addr = 0;
uint32 area_size = ((size - 1) / B_PAGE_SIZE + 1) * B_PAGE_SIZE ;
area_id area = create_area("meta_data_area", (void**)&addr, B_ANY_ADDRESS, area_size,
B_NO_LOCK, B_READ_AREA | B_WRITE_AREA);
if (area < 0) {
return area;
}
memcpy(addr, data, size);
set_area_protection(area,B_READ_AREA);
meta_data = addr;
meta_data_size = size; meta_data_size = size;
meta_data_area = area;
use_area = area;
thread_id thread = find_thread(NULL);
thread_info info;
if (get_thread_info(thread, &info) == B_OK) {
team = info.team;
}
thisPtr = this;
return B_OK; return B_OK;
} }
@@ -681,12 +702,10 @@ media_format::operator=(const media_format &clone)
// these things only happen when a meta_data_area is defined: // these things only happen when a meta_data_area is defined:
if (meta_data_area > 0) { if (meta_data_area > 0) {
thread_id thread = find_thread(NULL); thread_id thread = find_thread(NULL);
if (thread != B_NAME_NOT_FOUND) {
thread_info info; thread_info info;
if (get_thread_info(thread,&info) == B_OK) { if (get_thread_info(thread,&info) == B_OK) {
team = info.team; team = info.team;
} }
}
thisPtr = this; thisPtr = this;
// TODO: start _Media_Roster_ // TODO: start _Media_Roster_
// TODO: request the _Media_Roster_ to give us the // TODO: request the _Media_Roster_ to give us the