bool MediaIcon::_isConsumer() const { D_INTERNAL(("MediaIcon::_isConsumer()\n")); return ( (m_nodeKind & B_BUFFER_CONSUMER) && !(m_nodeKind & B_BUFFER_PRODUCER) && !(m_nodeKind & B_PHYSICAL_INPUT) && !(m_nodeKind & B_PHYSICAL_OUTPUT)); }
void CPlaybackTaskGroup::_changeTempo( long newRate, long start, long duration, long clockType) { D_INTERNAL(("CPlaybackTaskGroup::_changeTempo(%ld, %ld, %ld)\n", newRate, start, duration)); tempo.SetTempo(tempo, newRate, start, duration, (TClockType)clockType); }
void ParameterWindow::_updateParameterView( BMediaTheme *theme) { D_INTERNAL(("ParameterWindow::_updateParameterView()\n")); // clear the old version if (m_parameters) { ParameterContainerView *view = dynamic_cast<ParameterContainerView *>(FindView("ParameterContainerView")); RemoveChild(view); delete m_parameters; m_parameters = 0; delete view; } // fetch ParameterWeb from the MediaRoster BMediaRoster *roster = BMediaRoster::CurrentRoster(); if (roster) { BParameterWeb *web; status_t error = roster->GetParameterWebFor(m_node, &web); if (!error && (web->CountParameters() || web->CountGroups())) { // if no theme was specified, use the preferred theme if (!theme) { theme = BMediaTheme::PreferredTheme(); } // acquire the view m_parameters = BMediaTheme::ViewFor(web, 0, theme); if (m_parameters) { BMenuBar *menuBar = KeyMenuBar(); m_idealSize = m_parameters->Bounds(); m_idealSize.right += B_V_SCROLL_BAR_WIDTH; m_idealSize.bottom += B_H_SCROLL_BAR_HEIGHT; if (menuBar) { m_parameters->MoveTo(0.0, menuBar->Bounds().bottom + 1.0); m_idealSize.bottom += menuBar->Bounds().bottom + 1.0; } } } } // limit min size to avoid funny-looking scrollbars float hMin = B_V_SCROLL_BAR_WIDTH*6, vMin = B_H_SCROLL_BAR_HEIGHT*3; // limit max size to full extents of the parameter view float hMax = m_idealSize.Width(), vMax = m_idealSize.Height(); SetSizeLimits(hMin, hMax, vMin, vMax); // adapt the window to the new dimensions ResizeTo(m_idealSize.Width(), m_idealSize.Height()); m_zoomed = true; if (m_parameters) { BRect paramRect = m_parameters->Bounds(); AddChild(new ParameterContainerView(paramRect, m_parameters)); } }
void MediaIcon::_findIconFor( const live_node_info &nodeInfo) { D_INTERNAL(("MediaIcon::_findIconFor(live_node_info)\n")); BMediaRoster *roster = BMediaRoster::CurrentRoster(); if (m_nodeKind & B_FILE_INTERFACE) { entry_ref ref; if ((roster && (roster->GetRefFor(nodeInfo.node, &ref) == B_OK)) && (BNodeInfo::GetTrackerIcon(&ref, this, m_size) == B_OK)) { return; } } dormant_node_info dormantNodeInfo; if (roster && (roster->GetDormantNodeFor(nodeInfo.node, &dormantNodeInfo) == B_OK)) { D_INTERNAL((" -> instantiated from dormant node\n")); _findIconFor(dormantNodeInfo); } else { D_INTERNAL((" -> application internal node\n")); port_info portInfo; app_info appInfo; if ((get_port_info(nodeInfo.node.port, &portInfo) == B_OK) && (be_roster->GetRunningAppInfo(portInfo.team, &appInfo) == B_OK)) { D_INTERNAL((" -> application info found: %s\n", appInfo.signature)); app_info thisAppInfo; if ((be_app->GetAppInfo(&thisAppInfo) != B_OK) || ((strcmp(appInfo.signature, thisAppInfo.signature) != 0) && (strcmp(appInfo.signature, addon_host::g_appSignature) != 0))) { // only use app icon if the node doesn't belong to our team // or the addon-host BNodeInfo::GetTrackerIcon(&appInfo.ref, this, m_size); return; } } bool audioIn = false, audioOut = false, videoIn = false, videoOut = false; _getMediaTypesFor(nodeInfo, &audioIn, &audioOut, &videoIn, &videoOut); _findDefaultIconFor(audioIn, audioOut, videoIn, videoOut); } }
void ParameterWindow::_init() { D_INTERNAL(("ParameterWindow::_init()\n")); // offset to a new position _constrainToScreen(); m_manualSize = Bounds().OffsetToCopy(0.0, 0.0); // add the hidden option to close this window when the // control panel has been started successfully BMessage *message = new BMessage(M_START_CONTROL_PANEL); message->AddBool("replace", true); AddShortcut('P', B_COMMAND_KEY | B_SHIFT_KEY | B_OPTION_KEY, message); }
void CPlaybackTaskGroup::_locateNextChunk( TimeState &tState) { D_INTERNAL(("CPlaybackTaskGroup::_locateNextChunk()\n")); // Pop events off of the stack which are ready to go. Note that even // though the player will push events onto the stack in advance of when // they are needed, this code will not pop them until they are ready. // this means that when we start the piece, there may be stuff already // waiting on the stack. That's OK. CEvent ev; int32 count = 0; while (tState.stack.Pop(ev, tState.seekTime) && (count < LOCATE_MAX)) { _executeEvent(ev, tState); count++; } }
void RouteWindow::_constrainToScreen() { D_INTERNAL(("RouteWindow::_constrainToScreen()\n")); BScreen screen(this); BRect screenRect = screen.Frame(); BRect windowRect = Frame(); // if the window is outside the screen rect // move it to the default position if (!screenRect.Intersects(windowRect)) { windowRect.OffsetTo(screenRect.LeftTop()); MoveTo(windowRect.LeftTop()); windowRect = Frame(); } // if the window is larger than the screen rect // resize it to fit at each side if (!screenRect.Contains(windowRect)) { if (windowRect.left < screenRect.left) { windowRect.left = screenRect.left + 5.0; MoveTo(windowRect.LeftTop()); windowRect = Frame(); } if (windowRect.top < screenRect.top) { windowRect.top = screenRect.top + 5.0; MoveTo(windowRect.LeftTop()); windowRect = Frame(); } if (windowRect.right > screenRect.right) { windowRect.right = screenRect.right - 5.0; } if (windowRect.bottom > screenRect.bottom) { windowRect.bottom = screenRect.bottom - 5.0; } ResizeTo(windowRect.Width(), windowRect.Height()); } }
void MediaIcon::_findIconFor(const dormant_node_info &nodeInfo) { D_INTERNAL(("MediaIcon::_findIconFor(dormant_node_info)\n")); dormant_flavor_info flavorInfo; BMediaRoster *roster = BMediaRoster::CurrentRoster(); status_t error = roster->GetDormantFlavorInfoFor(nodeInfo, &flavorInfo); if (error == B_OK) { m_nodeKind = flavorInfo.kinds; bool audioIn = false, audioOut = false; bool videoIn = false, videoOut = false; _getMediaTypesFor(flavorInfo, &audioIn, &audioOut, &videoIn, &videoOut); _findDefaultIconFor(audioIn, audioOut, videoIn, videoOut); } else { // use generic icon in case we couldn't get any info if (m_size == B_LARGE_ICON) SetBits(M_GENERIC_ICON.large, 1024, 0, B_CMAP8); else if (m_size == B_MINI_ICON) SetBits(M_GENERIC_ICON.small, 256, 0, B_CMAP8); } }
void CPlaybackTaskGroup::_locate() { D_INTERNAL(("CPlaybackTaskGroup::_locate()\n")); CPlaybackTask *th[2]; th[0] = th[1] = NULL; // If the locator has to seek around in the sequence, then // kill all of the stuff that's playing now and re-launch // the master track. if (flags & (Locator_Reset | Locator_Find)) { LOCK_PLAYER; // Stop all notes for this song. FlushEvents(); if (flags & Locator_Reset) { // Stop all playback tasks for this song. _flushTasks(); real.seekTime = metered.seekTime = 0; // Launch each of the two main tracks for (int i = 0; i < 2; i++) { CEventTrack *tr = (CEventTrack *)mainTracks[i]; if (tr == NULL) continue; // REM: This use of "track duration" is incorrect if // both the master sequences are playing. CReadLock lock(tr); if (!tr->Events().IsEmpty()) { // Start the new tasks at time 0 with no parent task. if (tr->ClockType() == ClockType_Real) { int32 endTime = pbOptions & PB_Loop ? LONG_MAX : real.end; th[0] = new CRealClockEventTask(*this, (CEventTrack *)tr, NULL, 0, endTime); } else { int32 endTime = pbOptions & PB_Loop ? LONG_MAX : metered.end; th[1] = new CMeteredClockEventTask(*this, (CEventTrack *)tr, NULL, 0, endTime); } } } } flags &= ~(Locator_Reset | Locator_Find); } if (locateType == LocateTarget_Real) { // While seek time has not caught up to actual time, // locate through some number of events, except // if we're near the start of the song there's no need // to do any locating. while ((real.seekTime < real.time) && (real.time > 100)) { // Check once in a while to see if we have spent too much // time locating and didn't give other tasks a chance to run. // Also, check to see if the locate should be abandoned. if (flags & (Locator_Reset | Locator_Find)) return; LOCK_PLAYER; // Pop events off of the stack which are ready to go _locateNextChunk(real); metered.seekTime = tempo.ConvertRealToMetered(real.seekTime); _locateNextChunk(metered); if (!real.stack.NextTime(&real.seekTime)) real.seekTime = real.time; } } else { // While seek time has not caught up to actual time, // locate through some number of events, except // if we're near the start of the song there's no need // to do any locating. if (metered.time > 10) { while (metered.seekTime < metered.time) { // Check once in a while to see if we have spent too much // time locating and didn't give other tasks a chance to run. // Also, check to see if the locate should be abandoned. if (flags & (Locator_Reset | Locator_Find)) return; // Lock the player for another batch of events we are seeking. LOCK_PLAYER; _locateNextChunk(metered); real.seekTime = tempo.ConvertMeteredToReal(metered.seekTime); _locateNextChunk(real); int32 target = metered.time; if (pbOptions & PB_Folded) target = metered.time + metered.expansion; else target = metered.time; int32 nextTime; if (metered.stack.NextTime(&nextTime)) metered.seekTime = MIN(nextTime + cTrackAdvance_Metered, target); else metered.seekTime = target; } } // REM: I'm not sure this is right, but it works for now... real.time = tempo.ConvertMeteredToReal(metered.seekTime); } // Push back task origin so that lTime is correct. // REM: Is this correct for synced sequences??? // +++++ REMOVE THIS DEPENDANCY +++++ origin = thePlayer.m_internalTimerTick - real.time; flags &= ~Clock_Locating; // notify all destinations that locating has finished if (doc->ReadLock(500)) { CDestination *destination = NULL; int32 index = 0; bigtime_t now = system_time(); while ((destination = doc->GetNextDestination(&index)) != NULL) destination->DoneLocating(now); doc->ReadUnlock(); } // Poke the main player task to make sure it handles the first // event promptly. It doesn't have to actually do anything with // this command. write_port(thePlayer.Port(), Command_Attention, "", 0); }
void CPlaybackTaskGroup::_executeEvent( CEvent &ev, TimeState &tState) { D_INTERNAL(("CPlaybackTaskGroup::_executeEvent(%s)\n", ev.NameText())); switch (ev.Command()) { case EvtType_TaskMarker: { if (ev.task.taskPtr->flags & CPlaybackTask::Task_Finished) { delete ev.task.taskPtr; if (tasks.Empty()) { BMessage message(Player_ChangeTransportState); be_app->PostMessage(&message); } } else { ev.task.taskPtr->Play(); } return; } case EvtType_Interpolate: { // I was originally supposed to have executed at ev.Start() + timeStep, // but I may be a bit later than that -- take the difference into account. // Here's how much time has elapsed since I was dispatched... int32 elapsed = tState.time - ev.Start() + ev.interpolate.timeStep; // If we went past the end, then clip the time. if ((unsigned long)elapsed > ev.interpolate.duration) elapsed = ev.interpolate.duration; CDestination *dest = ev.common.destination; if (dest != NULL) { if (dest->ReadLock(500)) { dest->Interpolate(ev, tState.stack, system_time(), elapsed); dest->ReadUnlock(); } } return; } } CDestination *dest = ev.common.destination; if (dest != NULL) { if (dest->ReadLock(500)) { dest->Execute(ev, system_time()); dest->ReadUnlock(); } } }
bool MediaIcon::_isPhysicalOutput() const { D_INTERNAL(("MediaIcon::_isPhysicalOutput()\n")); return ((m_nodeKind & B_PHYSICAL_OUTPUT) && (m_nodeKind & B_BUFFER_CONSUMER));; }
bool MediaIcon::_isPhysicalInput() const { D_INTERNAL(("MediaIcon::_isPhysicalInput()\n")); return ((m_nodeKind & B_PHYSICAL_INPUT) && (m_nodeKind & B_BUFFER_PRODUCER)); }
void MediaIcon::_findDefaultIconFor( bool audioIn, bool audioOut, bool videoIn, bool videoOut) { D_INTERNAL(("MediaIcon::_findDefaultIcon()\n")); if (_isTimeSource()) { if (m_size == B_LARGE_ICON) SetBits(M_TIME_SOURCE_ICON.large, 1024, 0, B_CMAP8); else if (m_size == B_MINI_ICON) SetBits(M_TIME_SOURCE_ICON.small, 256, 0, B_CMAP8); return; } if (_isSystemMixer()) { if (m_size == B_LARGE_ICON) SetBits(M_AUDIO_MIXER_ICON.large, 1024, 0, B_CMAP8); else if (m_size == B_MINI_ICON) SetBits(M_AUDIO_MIXER_ICON.small, 256, 0, B_CMAP8); return; } if (m_nodeKind & B_FILE_INTERFACE) { if (_isProducer()) { if (m_size == B_LARGE_ICON) SetBits(M_FILE_READER_ICON.large, 1024, 0, B_CMAP8); else if (m_size == B_MINI_ICON) SetBits(M_FILE_READER_ICON.small, 256, 0, B_CMAP8); return; } else { if (m_size == B_LARGE_ICON) SetBits(M_FILE_WRITER_ICON.large, 1024, 0, B_CMAP8); else if (m_size == B_MINI_ICON) SetBits(M_FILE_WRITER_ICON.small, 256, 0, B_CMAP8); return; } } if (_isPhysicalInput()) { if (audioOut) { if (m_size == B_LARGE_ICON) SetBits(M_AUDIO_INPUT_ICON.large, 1024, 0, B_CMAP8); else if (m_size == B_MINI_ICON) SetBits(M_AUDIO_INPUT_ICON.small, 256, 0, B_CMAP8); return; } else if (videoOut) { if (m_size == B_LARGE_ICON) SetBits(M_VIDEO_INPUT_ICON.large, 1024, 0, B_CMAP8); else if (m_size == B_MINI_ICON) SetBits(M_VIDEO_INPUT_ICON.small, 256, 0, B_CMAP8); return; } } if (_isPhysicalOutput()) { if (audioIn) { if (m_size == B_LARGE_ICON) SetBits(M_AUDIO_OUTPUT_ICON.large, 1024, 0, B_CMAP8); else if (m_size == B_MINI_ICON) SetBits(M_AUDIO_OUTPUT_ICON.small, 256, 0, B_CMAP8); return; } else if (videoIn) { if (m_size == B_LARGE_ICON) SetBits(M_VIDEO_OUTPUT_ICON.large, 1024, 0, B_CMAP8); else if (m_size == B_MINI_ICON) SetBits(M_VIDEO_OUTPUT_ICON.small, 256, 0, B_CMAP8); return; } } if (_isProducer()) { if (audioOut) { if (m_size == B_LARGE_ICON) SetBits(M_AUDIO_PRODUCER_ICON.large, 1024, 0, B_CMAP8); else if (m_size == B_MINI_ICON) SetBits(M_AUDIO_PRODUCER_ICON.small, 256, 0, B_CMAP8); return; } else if (videoOut) { if (m_size == B_LARGE_ICON) SetBits(M_VIDEO_PRODUCER_ICON.large, 1024, 0, B_CMAP8); else if (m_size == B_MINI_ICON) SetBits(M_VIDEO_PRODUCER_ICON.small, 256, 0, B_CMAP8); return; } } if (_isFilter()) { if (audioIn && audioOut && !videoIn && !videoOut) { if (m_size == B_LARGE_ICON) SetBits(M_AUDIO_FILTER_ICON.large, 1024, 0, B_CMAP8); else if (m_size == B_MINI_ICON) SetBits(M_AUDIO_FILTER_ICON.small, 256, 0, B_CMAP8); return; } else if (audioIn && !videoIn && videoOut) { if (m_size == B_LARGE_ICON) SetBits(M_AUDIO_CONSUMER_ICON.large, 1024, 0, B_CMAP8); else if (m_size == B_MINI_ICON) SetBits(M_AUDIO_CONSUMER_ICON.small, 256, 0, B_CMAP8); return; } else if (!audioIn && !audioOut && videoIn && videoOut) { if (m_size == B_LARGE_ICON) SetBits(M_VIDEO_FILTER_ICON.large, 1024, 0, B_CMAP8); else if (m_size == B_MINI_ICON) SetBits(M_VIDEO_FILTER_ICON.small, 256, 0, B_CMAP8); return; } } if (_isConsumer()) { if (audioIn) { if (m_size == B_LARGE_ICON) SetBits(M_AUDIO_CONSUMER_ICON.large, 1024, 0, B_CMAP8); else if (m_size == B_MINI_ICON) SetBits(M_AUDIO_CONSUMER_ICON.small, 256, 0, B_CMAP8); return; } else if (videoIn) { if (m_size == B_LARGE_ICON) SetBits(M_VIDEO_CONSUMER_ICON.large, 1024, 0, B_CMAP8); else if (m_size == B_MINI_ICON) SetBits(M_VIDEO_CONSUMER_ICON.small, 256, 0, B_CMAP8); return; } } // assign a default icon if (m_size == B_LARGE_ICON) SetBits(M_GENERIC_ICON.large, 1024, 0, B_CMAP8); else if (m_size == B_MINI_ICON) SetBits(M_GENERIC_ICON.small, 256, 0, B_CMAP8); }
void MediaIcon::_getMediaTypesFor(const live_node_info &nodeInfo, bool *audioIn, bool *audioOut, bool *videoIn, bool *videoOut) { D_INTERNAL(("MediaIcon::_getMediaTypeFor(live_node_info)\n")); // get the media_types supported by this node const int32 numberOfInputs = 4; int32 numberOfFreeInputs, numberOfConnectedInputs; media_input inputs[numberOfInputs]; const int32 numberOfOutputs = 4; int32 numberOfFreeOutputs, numberOfConnectedOutputs; media_output outputs[numberOfOutputs]; BMediaRoster *roster = BMediaRoster::CurrentRoster(); if (roster->GetFreeInputsFor(nodeInfo.node, inputs, numberOfInputs, &numberOfFreeInputs) == B_OK) { for (int32 i = 0; i < numberOfFreeInputs; i++) { if ((inputs[i].format.type == B_MEDIA_RAW_AUDIO) || (inputs[i].format.type == B_MEDIA_ENCODED_AUDIO)) { *audioIn = true; continue; } if ((inputs[i].format.type == B_MEDIA_RAW_VIDEO) || (inputs[i].format.type == B_MEDIA_ENCODED_VIDEO)) { *videoIn = true; } } } if (roster->GetConnectedInputsFor(nodeInfo.node, inputs, numberOfInputs, &numberOfConnectedInputs) == B_OK) { for (int32 i = 0; i < numberOfConnectedInputs; i++) { if ((inputs[i].format.type == B_MEDIA_RAW_AUDIO) || (inputs[i].format.type == B_MEDIA_ENCODED_AUDIO)) { *audioIn = true; continue; } if ((inputs[i].format.type == B_MEDIA_RAW_VIDEO) || (inputs[i].format.type == B_MEDIA_ENCODED_VIDEO)) { *videoIn = true; } } } if (roster->GetFreeOutputsFor(nodeInfo.node, outputs, numberOfOutputs, &numberOfFreeOutputs) == B_OK) { for (int32 i = 0; i < numberOfFreeOutputs; i++) { if ((outputs[i].format.type == B_MEDIA_RAW_AUDIO) || (outputs[i].format.type == B_MEDIA_ENCODED_AUDIO)) { *audioOut = true; continue; } if ((outputs[i].format.type == B_MEDIA_RAW_VIDEO) || (outputs[i].format.type == B_MEDIA_ENCODED_VIDEO)) { *videoOut = true; } } } if (roster->GetConnectedOutputsFor(nodeInfo.node, outputs, numberOfOutputs, &numberOfConnectedOutputs) == B_OK) { for (int32 i = 0; i < numberOfConnectedOutputs; i++) { if ((outputs[i].format.type == B_MEDIA_RAW_AUDIO) || (outputs[i].format.type == B_MEDIA_ENCODED_AUDIO)) { *audioOut = true; continue; } if ((outputs[i].format.type == B_MEDIA_RAW_VIDEO) || (outputs[i].format.type == B_MEDIA_ENCODED_VIDEO)) { *videoOut = true; } } } }
bool MediaIcon::_isSystemMixer() const { D_INTERNAL(("MediaIcon::_isSystemMixer()\n")); return (m_nodeKind & B_SYSTEM_MIXER); }